package fatworm.query;

import java.util.Collection;

import fatworm.query.expression.Expression;
import fatworm.storage.table.*;
import fatworm.util.Lib;

public class ProjectPlan implements Plan {
	
	private Plan p;
	private Schema sch = new Schema();
	private Collection<Expression> selectlist; 
	
	public ProjectPlan(Plan p, Collection<Expression> selectlist) {
		this.p = p;
		this.selectlist = selectlist;
	}
	
	public Scan open() {
		return new ProjectScan(p.open(), selectlist);
	}
	
	public int blocksAccessed() {
		return p.blocksAccessed();
	}
	
	public int recordsOutput() {
		return p.recordsOutput();
	}
	
	public int distinctValues(String name) {
		if (sch.hasField(name))
			return p.distinctValues(name);
		else
			Lib.assertNotReached();
		return 0;
	}
	
	public Schema getSchema() {
		return sch;
	}
	
}